<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>店铺列表｜系统管理</title>
<script type="text/javascript">
    function showmabangorder(id)
    {
        $("#id").val(id);
        $.post("/management/ajaxbutton", {"op": "getkey","id":id,"id":id},
                function(data){
                    if(data.code){
                       $("#key").val(data.key);
                        $("#secret").val(data.secret);
						 $("#Ali_agent_visit").val(data.agent_visit);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#showmabangorder').modal('show');
    }
	
	function showamazon(id)
	{
		$("#editid").val(id);
		 $.post("/management/ajaxbutton", {"op": "getkey","id":id,"id":id},
                function(data){
                    if(data.code){
                      if(data.amazonkey)
					  {
						$("#stkey").val(data.amazonkey.SellerId);
						$("#stsecretkey").val(data.amazonkey.SecretKey);
						$("#MarketplaceId").val(data.amazonkey.MarketplaceId);
						$("#ACCESSId").val(data.amazonkey.ACCESSID);
						$("#SERVERURL").val(data.amazonkey.serverurl);
						$("#timezone").val(data.amazonkey.timezone);
						}
                    }else{
						$("#stkey").val('');
						$("#stsecretkey").val('');
						$("#MarketplaceId").val('');
						$("#ACCESSId").val('');
						$("#SERVERURL").val('');
						$("#timezone").val('');
                        //alert(data.msg);return ;
                    }
                },"json");
		$("#showamazon").modal('show');	
	}
	
    function authShops()
    {
        var key = $("#key").val();
        if(key=="")
        {
            alert("请输入appkey！");
            return;
        }
        var secret = $("#secret").val();
        if(secret=="")
        {
            alert("请输入appsecret！");
            return;
        }
        var id = $("#id").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
		var Ali_agent_visit = $("#Ali_agent_visit").val();
        $.post("/management/ajaxbutton", {"op": "auth","id":id,"key":key,"secret":secret,"Ali_agent_visit":Ali_agent_visit},
                function(data){
                    if(data.code){
                        location.href = data.url;
                    }else{
                        alert(data.msg);return ;
                    }
                },"json");
       //$("#modal_submit").submit();
    }
     function ebayauth(id)
    {
        $("#ebayid").val(id);
        $.post("/management/ajaxbutton", {"op": "getebaykey","ebayid":id},
                function(data){
                    if(data.code){
                       $("#ebaydevid").val(data.ebaydevid);
                        $("#ebayusertoken").val(data.ebayusertoken);
                        $("#ebayappid").val(data.ebayappid);
                        $("#ebaycertid").val(data.ebaycertid);
                        $("#ebaysiteid").val(data.ebaysiteid);
                        $("#ebaycompatabilitylevel").val(data.ebaycompatabilitylevel);
						$("#RuName").val(data.RuName);
						$("#agent_visit").val(data.agent_visit);
						$("#agent_site").val(data.agent_site);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#ebayauth').modal('show');
    }
    function magentoauth(id)
    {
        $("#magentoid").val(id);
        $.post("/management/ajaxbutton", {"op": "getmagentokey","magentoid":id},
                function(data){
                    if(data.code){
                       $("#magentotoken").val(data.magentotoken);
                       $("#magentourl").val(data.magentourl);
                       $("#magento1_user").val(data.magento1_user);
                       $("#magento1_key").val(data.magento1_key);
                       $("#magento2_consumerkey").val(data.magento2_consumerkey);
                       $("#magento2_consumersecret").val(data.magento2_consumersecret);
                       $("#magento2_accesstoken").val(data.magento2_accesstoken);
                       $("#magento2_accesstokensecret").val(data.magento2_accesstokensecret);
                       $("#magento2_username").val(data.magento2_username);
                       $("#magento2_password").val(data.magento2_password);
                       $("#magentov").val(data.magentov);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#magentoauth').modal('show');
    }
    
    //当改变magento 版本选择 则触发此函数
    $("#magentov").live("change",function(){
         v = $("#magentov").val();
         if(v=='1'){
            $(".magentov1").css('display','table-row');
            $(".magentov2").css('display','none');
         }else{
            $(".magentov2").css('display','table-row');
            $(".magentov1").css('display','none');            
         }
         });



    function shopeeauth(id)
    {
        $("#shopeeid").val(id);
        $.post("/management/ajaxbutton", {"op": "getshopeekey","shopeeid":id},
                function(data){
                    if(data.code){
                       $("#shopeetoken").val(data.shopeetoken);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#shopeeauth').modal('show');
    }

        function shopifyauth(id)
    {
        $("#shopifyid").val(id);
        $.post("/management/ajaxbutton", {"op": "getshopifykey","shopifyid":id},
                function(data){
                    if(data.code){
                       $("#shopifytoken").val(data.shopifytoken);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#shopifyauth').modal('show');
    }

     function wishauth(id)
    {
        $("#wishid").val(id);
        $.post("/management/ajaxbutton", {"op": "getwishkey","id":id},
                function(data){
                    if(data.code){
                       $("#wishkey").val(data.key);
                        $("#wishsecret").val(data.secret);
                         $("#wishurl").val(data.wishurl);
						 $("#wishagent_visit").val(data.agent_visit);
                    }else{
                        //alert(data.msg);return ;
                    }
                },"json");
        $('#wishauth').modal('show');
    }
    //wish 授权
    function wishauthShops()
    {
        var key = $("#wishkey").val();
        if(key=="")
        {
            alert("请输入Client Id！");
            return;
        }
        var secret = $("#wishsecret").val();
        if(secret=="")
        {
            alert("请输入Client Secret！");
            return;
        }
        var wishurl = $("#wishurl").val();
        if(wishurl=="")
        {
            alert("请输入wish回调地址");
            return;
        }
        var id = $("#wishid").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
		var wishagent_visit = $("#wishagent_visit").val();
        $.post("/management/ajaxbutton", {"op": "wishauth","wishid":id,"wishkey":key,"wishsecret":secret,"wishurl":wishurl,"wishagent_visit":wishagent_visit},
                function(data){
                    if(data.code){
                        location.href = data.url;
                    }else{
                        alert(data.msg);return ;
                    }
                },"json");
       //$("#modal_submit").submit();
    }

//ebay 授权
    function ebayauthShops()
    {
        var ebaydevid = $("#ebaydevid").val();
		var agent_visit=$("#agent_visit").val();
		var agent_site=$("#agent_site").val();
        if(ebaydevid=="")
        {
            alert("请输入devID！");
            return;
        }
       /* var ebayusertoken = $("#ebayusertoken").val();
        if(ebayusertoken=="")
        {
            alert("请输入user token！");
            return;
        }*/
        var id = $("#ebayid").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
         var ebayappid = $("#ebayappid").val();
        if(ebayappid=="")
        {
            alert("请输入app id！");
            return;
        }
          var ebaycertid = $("#ebaycertid").val();
        if(ebaycertid=="")
        {
            alert("请输入cert id！");
            return;
        }
             var ebaysiteid = $("#ebaysiteid").val();
        if(ebaysiteid=="")
        {
            alert("请输入site id！");
            return;
        }
		     var ebayusertoken = $("#ebayusertoken").val();
		
          var ebaycompatabilitylevel = $("#ebaycompatabilitylevel").val();
		  var RuName = $("#RuName").val();
        if(ebaycompatabilitylevel=="")
        {
            alert("请输入compatabilityLevel！");
            return;
        }
        $.post("/management/ajaxbutton",{"op":"ebayauth","ebayid":id,"ebaydevid":ebaydevid,"ebayappid":ebayappid,'ebaycertid':ebaycertid,'ebaycompatabilitylevel':ebaycompatabilitylevel,'agent_visit':agent_visit,'ebaysiteid':ebaysiteid,"ebayusertoken":ebayusertoken,'agent_visit':agent_visit,'RuName':RuName},
                function(data){
                    if(data.code=='1'){
                        alert(data.msg);
						$("#shouquan").show();
						if(data.url){
							window.open(data.url);
						}else{
							$("#shouquan").hide();
							$('#ebayauth').modal('hide');
						}
						return;
                    }else{
                        alert(data.msg);return;
                    }
                },"json");
       //$("#modal_submit").submit();
    }
function getebayauthShops()
{
	 var id = $("#ebayid").val();
	 $.post("/management/ajaxbutton",{"op":"shouquanebayauth","ebayid":id},
                function(data){
                    if(data.code=='1'){
                        alert(data.msg);
						$("#ebayusertoken").val(data.token);
						$("#shouquan").hide();
						return;
                    }else{
                        alert(data.msg);return;
                    }
                },"json");	
}
//magento 授权
    function magentoauthShops()
    {
        var magentotoken = $("#magentotoken").val();
        var magentourl = $("#magentourl").val();
        var magentov = $("#magentov").val();
        var magento1_user = $("#magento1_user").val();
        var magento1_key = $("#magento1_key").val();
        var magento2_consumerkey = $("#magento2_consumerkey").val();
        var magento2_consumersecret = $("#magento2_consumersecret").val();
        var magento2_accesstoken = $("#magento2_accesstoken").val();
        var magento2_accesstokensecret = $("#magento2_accesstokensecret").val();
        var magento2_username = $("#magento2_username").val();
        var magento2_password = $("#magento2_password").val();
        if(magentotoken=="")
        {
            alert("请输入magentotoken！");
            return;
        }
        if(magentourl=="")
        {
            alert("magentourl");
            return;
        }

        var id = $("#magentoid").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
       
        $.post("/management/ajaxbutton",{"op":"magentoauth","magentoid":id,"magentotoken":magentotoken,"magentourl":magentourl,"magento1_user":magento1_user,"magento1_key":magento1_key,"magento2_consumerkey":magento2_consumerkey,"magento2_consumersecret":magento2_consumersecret,"magento2_accesstoken":magento2_accesstoken,"magento2_accesstokensecret":magento2_accesstokensecret,"magento2_username":magento2_username,"magento2_password":magento2_password,"magentov":magentov},
                function(data){
                    if(data.code=='1'){
                        alert(data.msg);return;
                    }else{
                        alert(data.msg);return;
                    }
                },"json");
       //$("#modal_submit").submit();
    }

//shopee 授权
    function shopeeauthShops()
    {
        var shopeetoken = $("#shopeetoken").val();
        if(shopeetoken=="")
        {
            alert("请输入shopeetoken！");
            return;
        }
        var id = $("#shopeeid").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
       
        $.post("/management/ajaxbutton",{"op":"shopeeauth","shopeeid":id,"shopeetoken":shopeetoken},
                function(data){
                    if(data.code=='1'){
                        alert(data.msg);return;
                    }else{
                        alert(data.msg);return;
                    }
                },"json");
       //$("#modal_submit").submit();
    }

    //shopify 授权
    function shopifyauthShops()
    {
        var shopeetoken = $("#shopifytoken").val();
        if(shopeetoken=="")
        {
            alert("请输入shopifytoken！");
            return;
        }
        var id = $("#shopifyid").val();
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
       
        $.post("/management/ajaxbutton",{"op":"shopifyauth","shopifyid":id,"shopifytoken":shopeetoken},
                function(data){
                    if(data.code=='1'){
                        //alert(data.msg);return;
                        window.location.href=data.msg;return;
                    }else{
                        alert(data.msg);return;
                    }
                },"json");
       //$("#modal_submit").submit();
    }

	function authamazonShops()
	{
		var key = $("#stkey").val();
        if(key=="")
        {
            alert("请输入SellerId！");
            return;
        }	
		var secret = $("#stsecretkey").val();
        if(secret=="")
        {
            alert("请输入Secret Key！");
            return;
        }	
		var MarketplaceId = $("#MarketplaceId").val();
        if(MarketplaceId=="")
        {
            alert("请输入MarketplaceId！");
            return;
        }
		var ACCESSId = $("#ACCESSId").val();
        if(ACCESSId=="")
        {
            alert("请输入ACCESS Id！");
            return;
        }
		var SERVERURL = $("#SERVERURL").val();
        if(SERVERURL=="")
        {
            alert("请输入Url！");
            return;
        }
		var timezone = $("#timezone").val();
        if(timezone=="")
        {
            alert("请输入时区！");
            return;
        }
		var id = $("#editid").val();
		
		$.post("/management/ajaxbutton", {"op": "saveamazon","id":id,"stkey":key,"stsecretkey":secret,"MarketplaceId":MarketplaceId,"ACCESSId":ACCESSId,"SERVERURL":SERVERURL,"timezone":timezone},
			function(data){
				if(data){
					location.href = "/management/setshop";
				}else{
					alert(data.msg);return ;
				}
			},"json");
	}
    //删除店铺
    function delShops(id) {
        if(id=="")
        {
            alert("参数错误！");
            return;
        }
        $.post("/management/ajaxbutton", {"op": "del","id":id},
                function(data){
                    if(data.code){
                        location.reload();
                    }else{
                        alert(data.msg);return ;
                    }
                },"json");
    }

function selecturl()
{
	var amzurl = $("#amzurl").val();
	$("#SERVERURL").val(amzurl);
}

function BonanzaSubmit(){
	$("#bonanza_form").submit();	
}
//bonanza授权表单
function bonanzaAuth(id){
	$("#bo_shop_id").val(id);
	
	$.post("/bonanzaapi/request?op=getShopAuth", {"shop_id": id},
		function(ret){
			if(ret.id>0){
				$("#shop_name").html(ret.name);
				$("#platfromname").val(ret.aliexpressData);
				$("#boappkey").val(ret.appkey);
				$("#boappsecret").val(ret.appsecret);
				$("#access_token").val(ret.access_token);
				$("#refresh_token").val(ret.refresh_token);
				$("#openflag").val(ret.amazonkey);
				if(ret.access_token!=null){
					//$("#request_token_btn").hide();
				}else{
					$("#request_token_btn").show();
				}
				if(ret.refresh_token){
					$("#bonanza_auth_link").html(ret.refresh_token+' <a href="'+ret.refresh_token
					+'" target="_blank"><u>登录验证令牌生效</u></a>');
				}else{
					$("#bonanza_auth_link").empty();
				}
			}else{
				//alert(data.msg);return ;
			}
	},"json");
	$('#bonanzaForm').modal('show');
}

function requestToken(){
	var appkey=$("#boappkey").val();
	var appsecret=$("#boappsecret").val();
	if(appkey==''){
		alert('请先填写帐号的dev_id');
	}else if(appsecret==''){
		alert('请先填写帐号的cert_id');
	}else{
		$.post("/bonanzaapi/request?op=jsonGetToken", {"appkey": appkey,"appsecret":appsecret},
		function(ret){
			if(ret.state=='success'){
			   $("#access_token").val(ret.data.fetchTokenResponse.authToken);
			   var auth_url=ret.data.fetchTokenResponse.authenticationURL;
			   $("#refresh_token").val(auth_url)
			   $("#bonanza_auth_link").html(auth_url+' <a href="'+auth_url+'" target="_blank">登录验证令牌生效</a>');
			}else{
				alert(ret.msg);
			}
		},"json");
	}
}
</script>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent tables">
  <div class="pageheader notab">
    <h1 class="pagetitle">店铺列表</h1>
    <!--<span class="pagedesc">权限说明：职务为主管并且在帐号编辑中绑定了店铺。以及开通店铺设置权限。则主管可以编辑所绑定的店铺</span>--> 
    <div class="menulist">
                <ul class="profile_summary">
                      <li> <a href="ajaxbutton?op=addshop"><span>添加店铺</span></a></li>                    
                </ul>
            </div>
  </div>
  <!--pageheader-->
  
  <div id="contentwrapper" class="contentwrapper">
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    <!--搜索栏-->
    <form class="stdform stdform2" method="get" action="/management/setshop">
      <div class="tableoptions"> 平台:
        <select name="platformID" class="selection" style="width:100px;">
          <option value="" {{if $status==""}} selected{{/if}}>请选择</option>
          
                            {{foreach from=$platform item=li key=_key}}
                            
          <option value="{{$li.id}}" {{if $li.id==$platformID}} selected{{/if}}>{{$li.name}}</option>
          
                            {{/foreach}}
               
        </select>
        其他搜索:
        <input type="text" name="other" id="other" class="width100" value="{{$other}}" />
        <button class="btn btn_orange btn_search radius50">Search</button>
      </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
      <colgroup>
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      </colgroup>
      <thead>
        <tr>
          <th class="head0">NO</th>
          <th class="head0">店铺名称</th>
          <th class="head1">对应平台</th>
          <th class="head0">责任人</th>
          <th class="head0">创建时间</th>
          <th class="head0">获取数据方式</th>
          <th class="head0">操作</th>
        </tr>
      </thead>
      <tbody>
      
      {{foreach from=$list item=li key=key}}
      <tr>
        <td>{{$li.id}}</td>
        <td>{{$li.name}}</td>
        <td>{{$li.platfromname}}</td>
        <td>{{$li.updateoper}}</td>
        <td class="center">{{$li.creattime}}</td>
        <td class="center">{{if $li.agent_visit eq 1}}远程机访问{{else}}本地{{/if}}</td>
        <td class="center"> {{if $li.del_flag eq 0}} <a href="/management/ajaxbutton?op=editshop&id={{$li.id}}">编辑</a> ｜ <a href="javascript:void(0)" onClick="delShops({{$li.id}})"><span>删除</span></a> {{if $li.platfromname eq 'aliexpress'}}
          ｜ <a href="javascript:void(0)" onClick="showmabangorder({{$li.id}})"><span>授权</span></a> {{/if}}
          {{if $li.platfromname eq 'Amazon'}}
          ｜ <a href="javascript:void(0)" onClick="showamazon({{$li.id}})"><span>授权</span></a> {{/if}}
          {{else}} <span style="color:red;">已删除</span> {{/if}} 
            {{if $li.platfromname eq 'Bonanza'}}
                ｜
                <a href="javascript:void(0)" onClick="bonanzaAuth({{$li.id}})"><span>授权</span></a>
            {{/if}}
            {{if $li.platfromname eq 'Wish'}}
                ｜
                <a href="javascript:void(0)" onClick="wishauth({{$li.id}})"><span>授权</span></a>
            {{/if}}
             {{if $li.platfromname eq 'ebay'}}
                ｜
                <a href="javascript:void(0)" onClick="ebayauth({{$li.id}})"><span>授权</span></a>
            {{/if}}
            {{if $li.platfromname eq 'Magento'}}
                ｜
                <a href="javascript:void(0)" onClick="magentoauth({{$li.id}})"><span>授权</span></a>
            {{/if}}  
            {{if $li.platfromname eq 'Shopee'}}
                ｜
                <a href="javascript:void(0)" onClick="shopeeauth({{$li.id}})"><span>授权</span></a>
            {{/if}}
            {{if $li.platfromname eq 'Shopify'}}
                ｜
                <a href="javascript:void(0)" onClick="shopifyauth({{$li.id}})"><span>授权</span></a>
            {{/if}}
                    </td>
      </tr>
      {{/foreach}}
        </tbody>
    </table>
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    <br />
    <br />
  </div>
</div>
<!--bodywrapper--> 
<!-- 模态框（Modal）添加授权 -->
<form  method="post" id="modal_submit" action="/management/doShopAuth">
  <input type="hidden" name="id" id="id">
  <div class="modal fade" id="showmabangorder" tabindex="-1" role="dialog" aria-labelledby="sshowmabangorder" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowmabangorder">增加授权</h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="right">appKey： </td>
              <td align="left"><input type="text" name="key" id="key" value="" maxlength="200"  class="small_input">
                <input type="hidden" name="id" id="id" value="" maxlength="200"  class="small_input">
                <font color="#FF0000">(*必选项)</font></td>
            </tr>
            <tr>
              <td align="right">appScret： </td>
              <td align="left"><input type="text" name="secret" id="secret" value="" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
             <tr>
               <td align="right">访问方式：</td>
               <td align="left">
               <select id="Ali_agent_visit" name="Ali_agent_visit" class="small_input">
                    <option value="0">本地店铺</option>
                    <option value="1">远程店铺</option>
               </select></td>
             </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
            <button type="button" class="btn btn-primary" onClick="authShops()">授权</button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>


<!-- 模态框（Modal）添加亚马逊授权 -->
<form  method="post" id="bonanza_form" action="/bonanzaapi/request?op=saveAuth">
  <input type="hidden" name="bo_shop_id" id="bo_shop_id">
  <div class="modal fade" id="bonanzaForm" tabindex="-1" role="dialog" aria-labelledby="sshowamazon" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowamazon">设置bonanza <span id="shop_name"></span>店铺授权</h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="right" width="20%">店铺平台帐号： </td>
              <td align="left"><input type="text" name="platfromname" id="platfromname" value="" maxlength="20"  class="small_input">
                <font color="#FF0000">(*)</font></td>
            </tr>
            <tr>
              <td align="right" width="20%">帐号dev_id： </td>
              <td align="left"><input type="text" name="boappkey" id="boappkey" value="" style="width:200px;" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*用帐号登录<a href="https://api.bonanza.com/" target="_blank">Bonanza API中心</a>开通API帐号可获得)</font></td>
            </tr>
            <tr>
              <td align="right">帐号cert_id： </td>
              <td align="left"><input type="text" name="boappsecret" id="boappsecret" value="" style="width:200px;" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*)</font></td>
            </tr>
            <tr>
              <td align="right">授权令牌(token)： </td>
              <td align="left"><input type="text" name="access_token" id="access_token" value="" style="width:200px;" maxlength="200"  class="small_input" /> <button type="button" class="btn btn-primary" id="request_token_btn" onClick="requestToken()">获取授权令牌</button></td>
            </tr>
            <tr>
              <td align="right">授权链接： </td>
              <td align="left"><input type="hidden" name="refresh_token" id="refresh_token"><b id="bonanza_auth_link"></b> </td>
            </tr>
           
            <tr>
              <td align="right">授权状态： </td>
              <td align="left">
              <select name="openflag" id="openflag" class="select1">
                  <option value="0">未验证令牌</option>
                  <option value="1">已验证令牌</option>
                </select></td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
            <button type="button" class="btn btn-primary" onClick="BonanzaSubmit()">设置授权</button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>

<!-- 模态框（Modal）添加亚马逊授权 -->
<form  method="post" id="modal_submit" action="/management/doShopAuth">
  <input type="hidden" name="editid" id="editid">
  <div class="modal fade" id="showamazon" tabindex="-1" role="dialog" aria-labelledby="sshowamazon" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowamazon">增加Amazon授权</h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="right" width="20%">SellerId： </td>
              <td align="left"><input type="text" name="stkey" id="stkey" value="" maxlength="200"  class="small_input">
                <font color="#FF0000">(*必选项)</font></td>
            </tr>
            <tr>
              <td align="right">Secret Key： </td>
              <td align="left"><input type="text" name="stsecretkey" id="stsecretkey" value="" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td align="right">MarketplaceId： </td>
              <td align="left"><input type="text" name="MarketplaceId" id="MarketplaceId" value="" maxlength="200"  class="small_input" />
                <font color="#FF0000">多个市场ID用｜隔开,一个店铺多个国家</font></td>
            </tr>
            <tr>
              <td align="right">ACCESS ID： </td>
              <td align="left"><input type="text" name="ACCESSId" id="ACCESSId" value="" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td align="right">Url： </td>
              <td align="left"><input type="text" name="SERVERURL" id="SERVERURL" value="" maxlength="200"  class="small_input" />
              <select name="amzurl" id="amzurl" class="select1" style="width: 25%; border: 1px solid; border-color: #CED9DF; height: 30px;" onChange="selecturl()">
                  <option value=""> --请选择-- </option>
                  <option value="https://mws.amazonservices.com">https://mws.amazonservices.com</option>
                  <option value="https://mws.amazonservices.co.uk"> https://mws.amazonservices.co.uk </option>
                  <option value="https://mws.amazonservices.fr"> https://mws.amazonservices.fr </option>
                  <option value="https://mws.amazonservices.de"> https://mws.amazonservices.de </option>
                  <option value="https://mws.amazonservices.it"> https://mws.amazonservices.it </option>
                  <option value="https://mws.amazonservices.jp"> https://mws.amazonservices.jp </option>
                  <option value="https://mws.amazonservices.ca"> https://mws.amazonservices.ca </option>
                  <option value="https://mws.amazonservices.in"> https://mws.amazonservices.in </option>
                  <option value="https://mws.amazonservices.com.cn"> https://mws.amazonservices.com.cn </option>
                  <option value="https://mws.amazonservices.com.mx"> https://mws.amazonservices.com.mx </option>
                  <option value="https://mws.amazonservices.es"> https://mws.amazonservices.es </option>
                 
                </select>
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
           
            <tr>
              <td align="right">时区： </td>
              <td align="left"><input type="text" name="timezone" id="timezone" value="" maxlength="200"  class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
            <button type="button" class="btn btn-primary" onClick="authamazonShops()">授权</button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>
<!-- wish 授权 -->
<form  method="post" id="modal_submit" action="/management/wishauth">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="wishauth" tabindex="-1" role="dialog" aria-labelledby="wishauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="wishauth">增加授权</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">Client Id： </td>
                                <td align="left">
                                    <input type="text" name="key" id="wishkey" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <input type="hidden" name="id" id="wishid" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">Client Secret： </td>
                                <td align="left"><input type="text" name="secret" id="wishsecret" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">回调地址： </td>
                                <td align="left"><input type="text" name="secret" id="wishurl" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                             <tr>
                               <td align="right">访问方式：</td>
                               <td align="left">
                               <select id="wishagent_visit" name="agent_visit" class="small_input">
									<option value="0">本地访问获取数据</option>
                                    <option value="1">远程访问获取数据</option>
							   </select></td>
                             </tr>
                             <tr>
                                <td align="right">说明： </td>
                                <td align="left">第一步：输入WISH后台设置的Id和Secret
                                				<br>
                                                 第二步：WISH后台设置返回连接，每个连接需不一样
                                                 <br>
                                </td>
                            </tr>
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                            <button type="button" class="btn btn-primary" onClick="wishauthShops()">授权</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>


<!-- ebay 授权 -->
<form  method="post" id="modal_submit" action="/management/ebayauth">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="ebayauth" tabindex="-1" role="dialog" aria-labelledby="ebayauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">增加授权</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">devID： </td>
                                <td align="left">
                                    <input type="text" name="ebaydevid" id="ebaydevid" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input">
                                    <input type="hidden" name="ebayid" id="ebayid" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">userToken： </td>
                                <td align="left"><input type="text" name="ebayusertoken" id="ebayusertoken" value="" maxlength="2000" style="width:200px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">appID： </td>
                                <td align="left"><input type="text" name="ebayappid" id="ebayappid" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">certID： </td>
                                <td align="left"><input type="text" name="ebaycertid" id="ebaycertid" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">siteID: </td>
                                <td align="left"><input type="text" name="ebaysiteid" id="ebaysiteid" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">compatabilityLevel： </td>
                                <td align="left"><input type="text" name="ebaycompatabilitylevel" id="ebaycompatabilitylevel" value="" maxlength="200" style="width:200px;line-height:0.4;" class="small_input" />
                                    <font color="#FF0000">(*必填项)</font></td>
                            </tr>
                             <tr>
                               <td align="right">RuName：</td>
                               <td align="left"><input type="text" name="RuName" id="RuName" value="" maxlength="200" style="width:280px;line-height:0.4;" class="small_input" /></td>
                             </tr>
                             <tr>
                               <td align="right">访问方式：</td>
                               <td align="left">
                               <select id="agent_visit" name="agent_visit" class="small_input">
									<option value="0">本地访问获取数据</option>
                                    <option value="1">远程访问获取数据</option>
							   </select></td>
                             </tr>
                             <tr>
                               <td align="right">远程请求目录：</td>
                               <td align="left"><input type="text" name="agent_site" id="agent_site" value="" maxlength="200" style="width:280px;line-height:0.4;" class="small_input" /></td>
                             </tr>
                             
                             <tr>
                                <td align="right">说明： </td>
                                <td align="left">第一步：填写devID，appID，certID点击保存，等待几秒
                                				<br>
                                                 第二步：弹出提示后点击，跳转到ebay进行授权
                                                 <br>
                                                 第三步：授权完成后，回到该页面点击获取授权                                </td>
                            </tr>
                        </table>
          <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                            <button type="button" class="btn btn-primary"  onClick="ebayauthShops()">保存</button>
                            <span id="shouquan" style="display:none">
                           <button type="button" class="btn btn-primary" onClick="getebayauthShops()">获取授权</button></span>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>
<!-- magento 授权 -->
<form  method="post" id="modal_submit" action="/management/magentoauth">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="magentoauth" tabindex="-1" role="dialog" aria-labelledby="magentoauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">增加授权</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">magentotoken： </td>
                                <td align="left">
                                    <input type="text" name="magentotoken" id="magentotoken" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <input type="hidden" name="magentoid" id="magentoid" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">magentourl： </td>
                                <td align="left">
                                    <input type="text" name="magentourl" id="magentourl" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                            <tr>
                                <td align="right">magento 版本:</td>
                                <td align="left">
                                    <select name="magentov" id="magentov" style="width:100px;line-height:0.4;" class="small_input">
                                        <option value="0">请选择</option>
                                        <option value="1">1.x</option>
                                        <option value="2">2.x</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="magentov1" style="display: none;">
                                <td align="right">magento1_user:</td>
                                <td align="left">
                                    <input type="text" name="magento1_user" id="magento1_user" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov1" style="display: none;">
                                <td align="right">magento1_key:</td>
                                <td align="left">
                                    <input type="text" name="magento1_key" id="magento1_key" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_consumerKey:</td>
                                <td align="left">
                                    <input type="text" name="magento2_consumerkey" id="magento2_consumerkey" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_consumerSecret:</td>
                                <td align="left">
                                    <input type="text" name="magento2_consumersecret" id="magento2_consumersecret" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_accessToken:</td>
                                <td align="left">
                                    <input type="text" name="magento2_accesstoken" id="magento2_accesstoken" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_accessTokenSecret:</td>
                                <td align="left">
                                    <input type="text" name="magento2_accesstokensecret" id="magento2_accesstokensecret" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_username:</td>
                                <td align="left">
                                    <input type="text" name="magento2_username" id="magento2_username" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>
                            <tr class="magentov2" style="display: none;">
                                <td align="right">magento2_password:</td>
                                <td align="left">
                                    <input type="text" name="magento2_password" id="magento2_password" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                </td>
                            </tr>                           
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                            <button type="button" class="btn btn-primary" onClick="magentoauthShops()">授权</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>

<!-- shopee 授权 -->
<form  method="post" id="modal_submit" action="/management/shopeeauth">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="shopeeauth" tabindex="-1" role="dialog" aria-labelledby="shopeeauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">增加授权</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">shopid： </td>
                                <td align="left">
                                    <input type="text" name="shopeetoken" id="shopeetoken" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <input type="hidden" name="shopeeid" id="shopeeid" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                           
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                            <button type="button" class="btn btn-primary" onClick="shopeeauthShops()">授权</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>


<!-- shopify 授权 -->
<form  method="post" id="modal_submit" action="/management/shopifyauth">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="shopifyauth" tabindex="-1" role="dialog" aria-labelledby="shopifyauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">增加授权</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">shopname： </td>
                                <td align="left">
                                    <input type="text" name="shopifytoken" id="shopifytoken" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <input type="hidden" name="shopifyid" id="shopifyid" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input">
                                    <font color="#FF0000">(*必选项)</font></td>
                            </tr>
                           
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                            <button type="button" class="btn btn-primary" onClick="shopifyauthShops()">授权</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>



</body>
</html>